package com.example.petstoreservice.service;

import com.example.petstoreservice.entity.Product;
import com.example.petstoreservice.entity.Supplier;
import com.example.petstoreservice.mapper.SupplierMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SupplierService {
    @Autowired
    private SupplierMapper supplierMapper;
    public List<Supplier> getAll(){
        return supplierMapper.getAll();
    }
    public boolean delete(Long id){
        int affectRow= supplierMapper.delete(id);
        return affectRow>0;
    }
    public boolean update(Supplier supplier){
        int affectRow= supplierMapper.update(supplier);
        return affectRow>0;
    }
    public List<Supplier> search(String p){
        return supplierMapper.search(p);
    }
    public Supplier getById(Long supplierId){
        return supplierMapper.getById(supplierId);
    }
    public boolean insert(Supplier supplier){
        int affectRow= supplierMapper.insert(supplier);
        return affectRow>0;
    }

    public List<Supplier> findNearbyShops(double lng, double lat) {
        return supplierMapper.findNearbyShops(lng, lat);
    }
}
